
"use strict";

angular.module('app.project').controller('ProjectDetailCtrl', function ($scope, personalCenterHttp, projectHttpS, jurisHttpS, $http, $rootScope, $stateParams, $cookieStore) {
    
    var pid = $cookieStore.get("view_pid");
    var pcode = $cookieStore.get("view_pcode");
    $rootScope.pname = $cookieStore.get("view_pname");
    var c = false;//温度曲线标记
    //配置分页基本参数
    $scope.paginationConf = {
        currentPage: 1,
        itemsPerPage: 10,
        pagesLength: 5,
        totalItems: 20,
        perPageOptions: [10, 20, 30, 40, 50],

        onChange: function () {
        }
    };

    $("#myTab li a").click(function(){
        // console.log($(this).attr("href").replace("#",""))
        var tab = $(this).attr("href").replace("#","");
        if(tab == "detail"){//库存信息
            getdetail();
        }else if(tab == "ios"){//项目设备信息
            getios();
        }else if(tab == "store"){//油罐信息
            getstore();
        }
    })
    
    var full_pos = 13;
    
    getstore();
    /***油罐数据* start***/
    function getdetail(){
        if(pcode == undefined) pcode = 111;
        //项目库存信息
        var data = {query:0, data:{code: pcode}};
        $http.post("http://120.27.18.161:3001/api/system/inventory", data ,{withCredentials:false}).then(function(res){
            // console.log(res.data);
            if(res.status == 200){
                $scope.storelists = res.data;
            }else{
                //无库存信息
            }
        })
    }
    /***油罐数据* end***/
    

    /***设备信息* start***/
    function getios(){
        //当前项目的设备信息
        $http.post(baseurls+"/list/select/device?projectid=="+pid, $scope.paginationConf).then(function(res){
            // console.log(res.data)
            if(res.data.ret == 1){
                $scope.devices = res.data.rows;
                $scope.paginationConf.totalItems = res.data.records;
            }
        })
    }
    /***设备信息* end***/

    /***油罐信息* start***/
    $scope.infor = {}; // 油罐基本信息
    function getstore(){
        if(pid){
            //项目基本信息
            $http.get(baseurls+"/detail/project?id=="+pid,{withCredentials:true}).then(function(res){
                // console.log(res.data.info);
                if(res.data.ret == 1){
                    $scope.infor = res.data.info;
                }
            })
            //项目库存信息
            $http.get(baseurls+"/detail/inventory?code=="+pcode,{withCredentials:true}).then(function(res){
                // console.log(res.data);
                if(res.data.ret == 1){
                    $scope.store = res.data.info;
                }else{
                    //无库存信息
                }
            })
        }
    }
    /***油罐信息* end***/
  
});